<%@page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML>
<html lang="en">
<head>
    <!-- Force latest IE rendering engine or ChromeFrame if installed -->
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <![endif]-->
    <meta charset="utf-8">
    <title>jQuery File Upload Demo</title>
    <meta name="description"
          content="File Upload widget with multiple file selection, drag&amp;drop support, progress bars, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads and client-side image resizing. Works with any server-side platform (PHP, Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard HTML form file uploads.">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap styles -->
    <link rel="stylesheet" href="/x/zjabank/static/widget/bootstrap/css/bootstrap.min.css">
    <!-- blueimp Gallery styles -->
    <link rel="stylesheet" href="/x/zjabank/static/widget/fileupload/css/blueimp-gallery.min.css">
    <!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
    <link rel="stylesheet" href="/x/zjabank/static/widget/fileupload/css/jquery.fileupload.css">
    <link rel="stylesheet" href="/x/zjabank/static/widget/fileupload/css/jquery.fileupload-ui.css">
    <!-- CSS adjustments for browsers with JavaScript disabled -->
    <noscript>
        <link rel="stylesheet" href="/x/zjabank/static/widget/fileupload/css/jquery.fileupload-noscript.css">
    </noscript>
    <noscript>
        <link rel="stylesheet" href="/x/zjabank/static/widget/fileupload/css/jquery.fileupload-ui-noscript.css">
    </noscript>
    <style>
        body {
            padding: 15px;
        }

        .tab-pane .panel {
            border-top: 0px;
            margin-bottom: 0px;
        }

        .panel-default {
            border-color: #ddd;
        }

        .row {
            min-height: 20px;
        }
        .content{
            margin-top: 20px;
            text-indent: 2em;
        }
    </style>
</head>
<body>
<div id="body">

</div>
<!-- The blueimp Gallery widget -->
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
    <div class="slides"></div>
    <h3 class="title"></h3>
    <a class="prev">‹</a>
    <a class="next">›</a>
    <a class="close">×</a>
    <a class="play-pause"></a>
    <ol class="indicator"></ol>
</div>
<!-- The template to display files available for upload -->
<script id="panelTmpl" type="text/x-dot-template">
    <!-- The file upload form used as target for the file upload widget -->
    <ul class="nav nav-tabs" role="tablist">
        {{ for(var i=1;i<=it.length;i++){ }}
        <li class="{{? i===1}}active{{?}}">
            <a class="containerBtn" href="#container{{=i}}" role="tab" data-toggle="tab" key="{{=it[i-1]['type']}}">{{=it[i-1]['title']}}</a>
        </li>
        {{ } }}
        </li>
    </ul>
    <div class="tab-content">

        {{ for(var i=1;i<=it.length;i++){ }}
        <div class="tab-pane {{? i===1}}active choused{{?}}" id="container{{=i}}">
            <div class="panel panel-default">
                <div class="container">
                    <p class="content">{{=it[i-1]['content']}}</p>
                    {{?!it[i-1]['children']}}
                    <form class="fileupload" action="/server/upload/upload" method="POST"
                          enctype="multipart/form-data">
                        <input type="hidden" name="busiId" value="${busiId}"/>
                        <input type="hidden" name="busiCode" value="{{=it[i-1]['type']}}"/>
                        <div class="row fileupload-buttonbar">
                            <c:if test="${uploadRole}">
                            <div class="col-lg-7">
                                <input type="checkbox" class="toggle">
                                <!-- The fileinput-button span is used to style the file input field as button -->
                            <span class="btn btn-success fileinput-button">
                                <i class="glyphicon glyphicon-plus"></i>
                                <span>添加文件</span>
                                <input type="file" name="myfile" multiple>
                            </span>
                                <button type="submit" class="btn btn-primary start">
                                    <i class="glyphicon glyphicon-upload"></i>
                                    <span>批量上传</span>
                                </button>
                                <button type="reset" class="btn btn-warning cancel">
                                    <i class="glyphicon glyphicon-ban-circle"></i>
                                    <span>取消上传</span>
                                </button>
                                <button type="button" class="btn btn-danger delete">
                                    <i class="glyphicon glyphicon-trash"></i>
                                    <span>批量删除</span>
                                </button>
                                <!-- The global file processing state -->
                                <span class="fileupload-process"></span>
                            </div>
                            <!-- The global progress state -->
                            <div class="col-lg-5 fileupload-progress fade">
                                <!-- The global progress bar -->
                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0"
                                     aria-valuemax="100">
                                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                                </div>
                                <!-- The extended global progress state -->
                                <div class="progress-extended">&nbsp;</div>
                            </div>
                            </c:if>
                        </div>
                        <!-- The table listing the files available for upload/download -->
                        <table role="presentation" class="table table-striped">
                            <tbody class="files" mark="{{=i}}"></tbody>
                        </table>
                    </form>
                    {{??it[i-1]['children'].length>0}}
                    {{for(var j=1;j<=it[i-1]['children'].length;j++){}}
                    <p class="content">{{=it[i-1]['children'][j-1]['content']}}</p>
                    <form class="fileupload" action="/server/upload/upload" method="POST"
                          enctype="multipart/form-data">
                        <input type="hidden" name="busiId" value="${busiId}"/>
                        <input type="hidden" name="busiCode" value="{{=it[i-1]['children'][j-1]['type']}}"/>
                        <div class="row fileupload-buttonbar">
                            <c:if test="${uploadRole}">
                            <div class="col-lg-7">
                                <input type="checkbox" class="toggle">
                                <!-- The fileinput-button span is used to style the file input field as button -->
                            <span class="btn btn-success fileinput-button">
                                <i class="glyphicon glyphicon-plus"></i>
                                <span>添加文件</span>
                                <input type="file" name="myfile" multiple>
                            </span>
                                <button type="submit" class="btn btn-primary start">
                                    <i class="glyphicon glyphicon-upload"></i>
                                    <span>批量上传</span>
                                </button>
                                <button type="reset" class="btn btn-warning cancel">
                                    <i class="glyphicon glyphicon-ban-circle"></i>
                                    <span>取消上传</span>
                                </button>
                                <button type="button" class="btn btn-danger delete">
                                    <i class="glyphicon glyphicon-trash"></i>
                                    <span>批量删除</span>
                                </button>
                                <!-- The global file processing state -->
                                <span class="fileupload-process"></span>
                            </div>
                            <!-- The global progress state -->
                            <div class="col-lg-5 fileupload-progress fade">
                                <!-- The global progress bar -->
                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0"
                                     aria-valuemax="100">
                                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                                </div>
                                <!-- The extended global progress state -->
                                <div class="progress-extended">&nbsp;</div>
                            </div>
                            </c:if>
                        </div>
                        <!-- The table listing the files available for upload/download -->
                        <table role="presentation" class="table table-striped">
                            <tbody class="files" mark="{{=i}}.{{=j}}"></tbody>
                        </table>
                    </form>
                    {{ } }}
                    {{?}}
                </div>
            </div>
        </div>
        {{ } }}
    </div>
</script>

<script id="template-upload" type="text/x-dot-template">
    {{ for (var i=0, file; file=it.files[i]; i++) { }}
    <tr class="template-upload fade">
        <td>
            <span class="preview"></span>
        </td>
        <td>
            <p class="name">{{=file.name}}</p>
            <strong class="error text-danger"></strong>
        </td>
        <td>
            <p class="size">Processing...</p>

            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"
                 aria-valuenow="0">
                <div class="progress-bar progress-bar-success" style="width:0%;"></div>
            </div>
        </td>
        <td>
            {{ if (!i && !it.options.autoUpload) { }}
            <button class="btn btn-primary start" disabled>
                <i class="glyphicon glyphicon-upload"></i>
                <span>开始</span>
            </button>
            {{ } }}
            {{ if (!i) { }}
            <button class="btn btn-warning cancel">
                <i class="glyphicon glyphicon-ban-circle"></i>
                <span>取消</span>
            </button>
            {{ } }}
        </td>
    </tr>
    {{ } }}

</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-dot-template">
    {{ for (var i=0, file; file=it.files[i]; i++) { }}
    <tr class="template-download fade">
        <td>
            {{ if (file.deleteUrl) { }}
            <input type="checkbox" name="delete" value="1" class="toggle">
            {{ } }}
        </td>
        <td>
            <span class="preview">
                {{ if (file.thumbnailUrl) { }}
                    <a href="{{=file.url}}" title="{{=file.name}}" download="{{=file.name}}" data-gallery><img
                            src="{{=file.thumbnailUrl}}"></a>
                {{ } }}
            </span>
        </td>
        <td>
            <p class="name">
                {{ if (file.url) { }}
                <a href="{{=file.url}}" title="{{=file.name}}" download="{{=file.name}}"
                   {{=file.thumbnailUrl?'data-gallery':''}}>{{=file.name}}</a>
                {{ } else { }}
                <span>{{=file.name}}</span>
                {{ } }}
            </p>
            {{ if (file.error) { }}
            <div><span class="label label-danger">Error</span> {{=file.error}}</div>
            {{ } }}
        </td>
        <td>
            <span class="size">{{=it.formatFileSize(file.size)}}</span>
        </td>
        <td>
            {{ if (file.deleteUrl) { }}
            <c:if test="${uploadRole}">
            <button class="btn btn-danger delete" data-type="{{=file.deleteType}}" data-url="{{=file.deleteUrl}}" {{ if
                    (file.deleteWithCredentials) { }} data-xhr-fields='{"withCredentials":true}' {{ } }}>
                <i class="glyphicon glyphicon-trash"></i>
                <span>删除</span>
            </button>
            </c:if>
            {{ } else { }}
            <button class="btn btn-warning cancel">
                <i class="glyphicon glyphicon-ban-circle"></i>
                <span>取消</span>
            </button>
            {{ } }}
        </td>
    </tr>
    {{ } }}

</script>
<script src="/x/zjabank/static/js/jquery-1.11.3.min.js"></script>
<!-- The Templates plugin is included to render the upload/download listings -->
<script src="/x/zjabank/static/js/doT.min.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="/x/zjabank/static/widget/fileupload/js/load-image.all.min.js"></script>
<script src="/x/zjabank/static/widget/fileupload/js/vendor/jquery.ui.widget.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="/x/zjabank/static/widget/fileupload/js/canvas-to-blob.min.js"></script>
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
<script src="/x/zjabank/static/widget/bootstrap/js/bootstrap.min.js"></script>
<!-- blueimp Gallery script -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.blueimp-gallery.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload.js"></script>
<!-- The File Upload processing plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-process.js"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-image.js"></script>
<!-- The File Upload audio preview plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-audio.js"></script>
<!-- The File Upload video preview plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-video.js"></script>
<!-- The File Upload validation plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-validate.js"></script>
<!-- The File Upload user interface plugin -->
<script src="/x/zjabank/static/widget/fileupload/js/jquery.fileupload-ui.js"></script>
<!-- The main application script -->
<script type="text/javascript">
    $(function () {
        var busiCode = '${busiCode}';
        var type;
        //初步生成页面
        if(busiCode=='debt' || busiCode=='change'){
            type = [
                {
                    "type": busiCode+"1",
                    "title": "类型1",
                    "content": "1.盖公章后的申请表扫描件。"
                },
                {
                    "type": busiCode+"2",
                    "title": "类型2",
                    "content": "2.盖公章后的警示函扫描件。"
                },
                {
                    "type": busiCode+"3",
                    "title": "类型3",
                    "content": "3.社会统一信用代码证（或组织机构代码证）扫描件。"
                },
                {
                    "type": busiCode+"4",
                    "title": "类型4",
                    "content": "4.公检法进程中的立案、判决等生效法律文书。",
                    "children":[]
                },
                {
                    "type": busiCode+"5",
                    "title": "类型5",
                    "content": "5、选择使用（一）、（二）、（五）项联合惩戒措施，所需提交的具有法律效力的依据。",
                    "children":[]
                },
                {
                    "type": busiCode+"6",
                    "title": "类型6",
                    "content": "6.司法机关认可的第三方机构出具的鉴定文书、逃废债行为的事实依据,以及其他可作为依据的证明材料。"
                }
            ];
            //公安机关是否已立案
            if('${police_rState}'=='1'){
                type[3].children.push({"type":busiCode+"4.1","content": "公安机关已立案,必须上传立案生效法律文书"});
            }
            //是否已进入司法程序
            if('${justice_state}'=='1'){
                type[3].children.push({"type":busiCode+"4.2","content": "已进入司法程序,必须上传法院立案生效法律文书"});
            }
            //是否已进入法院执行程序
            if('${justice_exeState}'=='1'){
                type[3].children.push({"type":busiCode+"4.3","content": "已进入法院执行程序,必须上传判决生效法律文书"});
            }
            if('${sanction_mode}'.indexOf('1010')>0){
                type[4].children.push({"type":busiCode+"5.1","content": "选择使用（一）项联合惩戒措施，必须上传的具有法律效力的依据"});
            }
            if('${sanction_mode}'.indexOf('1020')>0){
                type[4].children.push({"type":busiCode+"5.2","content": "选择使用（二）项联合惩戒措施，必须上传的具有法律效力的依据"});
            }
            if('${sanction_mode}'.indexOf('1050')>0){
                type[4].children.push({"type":busiCode+"5.3","content": "选择使用（五）项联合惩戒措施，必须上传的具有法律效力的依据"});
            }
        }else if(busiCode=='noticecancel') {//警示撤销
            type = [
                {
                    "type": busiCode + "1",
                    "title": "类型1",
                    "content": "1.盖公章后的警示函扫描件。"
                },
                {
                    "type": busiCode + "2",
                    "title": "类型2",
                    "content": "2.撤销的事实依据。"
                }
            ];
        }else if(busiCode=='cancel'){//发布后撤销
            type = [
                {
                    "type": busiCode + "1",
                    "title": "类型1",
                    "content": "1.盖公章后的撤销申请表扫描件。"
                },
                {
                    "type": busiCode + "2",
                    "title": "类型2",
                    "content": "2.撤销的事实依据。"
                }
            ];
        }
        var tmpl = doT.template($("#panelTmpl").html());
        $("#body").html(tmpl(type));
        // Initialize the jQuery File Upload widget:
        $('.fileupload').each(function(m,n){
            $(this).fileupload({
                geturl: '/server/upload/list/' + $(this).find("input[name='busiCode']").val() + '/' + $(this).find("input[name='busiId']").val()
            });
        });
        $('.fileupload').fileupload('list');
        // Load existing files:
//        $('#fileupload1').addClass('fileupload-processing');
//        $.ajax({
//            // Uncomment the following to send cross-domain cookies:
//            //xhrFields: {withCredentials: true},
//            url: $('#fileupload1').fileupload('option', 'geturl'),
//            dataType: 'json',
//            context: $('#fileupload1')[0]
//        }).always(function () {
//            $(this).removeClass('fileupload-processing');
//        }).done(function (result) {
//            $(this).fileupload('option', 'done')
//                    .call(this, $.Event('done'), {result: result});
//        });
    });
</script>
<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9 -->
<!--[if (gte IE 8)&(lt IE 10)]>
<script src="/x/zjabank/static/js/cors/jquery.xdr-transport.js"></script>
<![endif]-->
</body>
</html>
